//package com.camel.system.config;
//
//import cn.dev33.satoken.context.SaHolder;
//import cn.dev33.satoken.filter.SaServletFilter;
//import cn.dev33.satoken.router.SaHttpMethod;
//import cn.dev33.satoken.router.SaRouter;
//import com.camel.core.entity.Result;
//import com.camel.core.utils.ResultUtil;
//import org.springframework.context.annotation.Bean;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.config.annotation.CorsRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
//@Component
//public class CORSConfig {
//
//
//    @Bean
//    public SaServletFilter getSaServeletFilter() {
//        return new SaServletFilter()
//                .addInclude("/**")
//                .addExclude("/favicon.ico")
//                .setAuth(obj -> {
//
//                })
//                .setError(e -> {
//                    return ResultUtil.error(500, e.getMessage());
//                })
//                .setBeforeAuth(obj -> {
//                    SaHolder.getResponse()
//                    .setHeader("Access-Control-Allow-Origin", "*")
//                    .setHeader("Access-Control-Allow-Credentials","true")
//                    .setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE")
//                    .setHeader("Access-Control-Max-Age", "31536000")
//                    .setHeader("Access-Control-Allow-Headers", "*");
//
//                    SaRouter.match(SaHttpMethod.OPTIONS)
//                            .free(r -> System.out.println("--------OPTIONS预检请求，不做处理"))
//                            .back();
//                });
//    }
//}
